﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class GameController : MonoBehaviour
{
    //声明时间
    public Text sumTime;
    //声明分数
    public Text score;
    //时间
    private float time, startTime;
    // Start is called before the first frame update
    void Start()
    {
        //记录游戏开始时间
        startTime = Time.time;
    }

    // Update is called once per frame
    void Update()
    {
        SumTime();
    }

    //统计时间
    void SumTime() {
        //根据文件夹路径绑定文件
        sumTime = GameObject.Find("Canvas/SumTime").GetComponent<Text>();
        //计算时间差
        time = Time.time - startTime;
        //调整时间格式
        int minutes = (int)time / 60;
        int seconds = (int)time % 60;
            //00为占位符，表示两个占位符
        string StrTime = string.Format("{0:00}:{1:00}", minutes, seconds);
        sumTime.text = "计时 "+StrTime;
    }
    //计分器功能
    void SumScore() { 
          
    }
}
